import 'package:flutter/material.dart';
import '../../routers/application.dart';
import '../../model/bizmodel.dart';

class MROrderList extends StatefulWidget {
  final List <MROrder> items;
  MROrderList({Key key, this.items}) : super(key: key);

  @override
  _MROrderListState createState() => _MROrderListState();
}

class _MROrderListState extends State<MROrderList> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
        child: ListView.builder(
            itemCount: this.widget.items.length,
            primary: true,
            padding: const EdgeInsets.all(5.0),
            itemBuilder: (context, index) {
              return GestureDetector(
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    FadeInImage.assetNetwork(
                      placeholder: "assets/images/house.png",
                      image: this.widget.items[index].engineerAvatar,
                      width: 60,
                      height: 60,
                    ),
                    SizedBox(width: 15),
                    Expanded(
                        child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            Text(this.widget.items[index].engineerName.toString(),
                                style: TextStyle(fontSize: 12)),
                            Image(
                                height: 10,
                                image: AssetImage(
                                    "assets/images/star${this.widget.items[index].engineerStar}.png"))
                          ],
                        ),
                        Text(this.widget.items[index].title),
                      ],
                    )),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: <Widget>[
                        Text(RepairStatus.describe(
                            this.widget.items[index].status)),
                        Text(
                            AppraiseStatus.describe(
                                this.widget.items[index].appraised),
                            style: TextStyle(fontSize: 12)),
                      ],
                    )
                  ],
                ),
                onTap: () {
                  Application.router.navigateTo(context, "/mr-order-page/${this.widget.items[index].id}/true");
                },
              );
            }));
  }
}
